<template>
  <div class="content-Modal">
    <cus-modal ref="modal" width="540" title="审核记录" :closable="false">
      <div
        :style="{ height: data.length > 0 ? '190px' : '' }"
        style="overflow-y: auto; overflow-x: hidden"
      >
        <div class="mb_10" v-for="(item, index) in data" :key="index">
          <div class="fl mb_10">
            <div>
              {{ new Date(item.gmtCreate).Format("yyyy-MM-dd hh:mm:ss") }}
            </div>
            <div class="text ml_20">{{ item.applyComment }}</div>
          </div>
          <div>
            <p class="ml_10">
              {{
                item.auditComment
                  ? `(${index + 1}) 、${item.auditComment}`
                  : "暂无!"
              }}
            </p>
          </div>
        </div>
      </div>
      <Input
        class="inputStyle"
        v-model="auditComment"
        type="textarea"
        maxlength="100"
        show-word-limit
        :autosize="{ minRows: 7, maxRows: 7 }"
        placeholder="请输入提交意见..."
      />
      <div slot="footer">
        <slot name="footer">
          <div class="modal-footer">
            <cus-button type="success" size="small" @onClick="onOk()">{{
              getShowText()
            }}</cus-button>
            <cus-button
              class="mr_20"
              type="primary"
              size="small"
              @onClick="onCancel()"
              >取消</cus-button
            >
          </div>
        </slot>
      </div>
      <Spin size="large" fix v-if="loading"></Spin>
    </cus-modal>
  </div>
</template>

<script>
import {
  postPurchasePlanReview,
  postPurchasePlanReviewRecord,
  getQueryLog,
} from "@/api/business/dishesModule";

export default {
  name: "",
  computed: {},
  data() {
    return {
      loading: false,
      form: {},
      data: [], // 提交Excel效验接口返回提示err
      auditComment: "", // 审核意见
    };
  },
  mounted() {},
  methods: {
    getShowText() {
      let auditState = this.form.auditState;
      let text = "";
      if (auditState == 0) {
        text = "审核";
      } else if (auditState == 2) {
        text = "上报审核";
      } else if (auditState == 3 || auditState == 4) {
        text = "重新上报";
      }
      return text;
    },
    show(data) {
      this.$refs["modal"].show = true;
      this.auditComment = "";
      this.form = data;
      this.getQueryLog();
    },
    onOk() {
      let params = new Object();
      params.mealPlanId = this.form.mealPlanId;
      params.auditComment = this.auditComment;
      params.autoStatus = this.form.autoStatus;
      this.$emit("onSendModal", params);
      this.$refs["modal"].show = false;
    },
    onCancel() {
      this.$refs["modal"].show = false;
    },
    // 审核记录-------------------------------接口
    getQueryLog() {
      return new Promise((resolve) => {
        let params = {
          mealPlanId: this.form.mealPlanId,
        };
        getQueryLog(params).then((res) => {
          if (res.retCode == 2000) {
            this.data = res.data;
            resolve();
          }
        });
      });
    },
    // 审核------------------------------------接口
    postPurchasePlanReviewApi() {
      this.$cu.showLoading();
      return new Promise((resolve) => {
        let params = {
          purchasingPlanId: this.form.id,
          auditComment: this.auditComment,
        };
        postPurchasePlanReview(params).then((res) => {
          this.$cu.hideLoading(1);
          if (res.retCode == 2000) {
            this.$Message.success(res.retMsg);
            this.$parent.postApiPurchasingGetAllPurchasingPlanPageApi();
            this.onCancel();
            resolve();
          }
        });
      });
    },
  },
  computed: {},
  watch: {},
};
</script>

<style lang="less" scoped>
// .content-Modal {
/deep/.modal-header {
  display: flex;
  justify-content: center;
  font-size: 20px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
  line-height: 23px;
}
/deep/.ivu-modal-header {
  border-bottom: none;
}
/deep/.ivu-modal-footer {
  border-top: none;
}
.mt_10 {
  margin-top: 10px;
}
.fl {
  display: flex;
}
.text {
  font-size: 14px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: #1e6fff;
}
.inputStyle {
  background: #f3f5f9;
  border-radius: 6px 6px 6px 6px;
  opacity: 1;
  margin-top: 10px;
  margin-bottom: -20px;
}
/*
*滚动条样式
*/
::-webkit-scrollbar {
  width: 10px;

  height: 16px;

  background-color: #f5f5f5;
}

/*定义滚动条轨道

内阴影+圆角*/

::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);

  border-radius: 10px;

  background-color: #f5f5f5;
}

/*定义滑块

内阴影+圆角*/

::-webkit-scrollbar-thumb {
  border-radius: 10px;

  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);

  background-color: #2d8cf0;
}
// }
</style>
